﻿@{
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}
@section ScriptAndCss{
    <link href="@Url.Content("~/Content/css/plan.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/plan.js")" type="text/javascript"></script>
}
<div class="padding5">
    <div>
        <table id="interfaceList" style="height: auto; min-height: 240px;" class="" title="一般计划接口人维护" url="/PlanManagement/GetPlanLocationOwner"
            fitcolumns="true" singleselect="true">
            <thead>
                <tr>
                    <th field="ID" width="140" sortable="true" hidden="true"></th>
                    <th field="LocationName" width="140" sortable="true">位置</th>
                    <th field="OwnerName" width="140" sortable="true">接口人</th>
                </tr>
            </thead>
        </table>
    </div>
    <div class="padding20">
        计划接口人：
        <input type="text" id="interfacePeople" disabled="disabled" data-from="username" />
        <input type="hidden" id="interfacePeopleID" data-from="userid" />
        <span class="icon-search" onclick="openSearchUser(true);"></span>
        <input type="button" value="保存" onclick="addInterface();" />
    </div>
</div>

<script type="text/javascript">

    var addInterface = function () {
        $.post('/PlanManagement/SavePlanLocationOwner', {
            ownerID: $('#interfacePeopleID').val()
        }, function (res) {
            if (res && res == "OK") {
                $.messager.alert('提示', '保存成功!', 'info', function () {
                    $('#interfaceList').datagrid('reload');
                });
            } else {
                $.messager.alert('错误', '保存失败!', 'error');
            }
        });
    };

    $(function () {
        $('#interfaceList').datagrid({
            onLoadSuccess: function (data) {
                if (data && data.rows.length) {
                    $('#interfacePeople').val(data.rows[0]["OwnerName"]);
                    $('#interfacePeopleID').val(data.rows[0]["OwnerID"]);
                }
            }
        });
    });
</script>
